import request from '@/utils/request'
// 查询【请填写功能名称】列表
export function listbill(query) {
  return request({
    url: '/lgorder/order/getlist',
    method: 'get',
    params: query
  })
}
export function getlistall(query) {
  return request({
    url: '/lgorder/order/getAll',
    method: 'get',
    params: query
  })
}
// 查询id查询订单
export function getBillById(id) {
  return request({
    url: '/lgorder/order/getInfo/' + id,
    method: 'get'
  })
}
// 修改订单
export function updateBill(data) {
  return request({
    url: '/lgorder/order/edit',
    method: 'post',
    data: data
  })
}

//新增订单
export function addBill(data) {
  return request({
    url: '/lgorder/order/add',
    method: 'post',
    data: data
  })
}
// 删除订单
export function delBill(billId) {
  return request({
    url: '/lgorder/order/remove/' + billId,
    method: 'get'
  })
}
//查询司机列表
export function listdriver(query) {
  return request({
    url: '/lgorder/order/getlistdriver',
    method: 'get',
    params: query
  })
}
export function listcar(query) {
  return request({
    url: '/lgorder/order/getlistcar',
    method: 'get',
    params: query
  })
}

// 指派司机
export function assignDriverToOrder(orderNumber, driverId) {
  return request({
    url: '/lgorder/order/driver', // 后端接收指派车辆的接口路径
    method: 'post',
    data: {
      orderNumber: orderNumber, // 传递订单编号
      driverId: driverId // 传递车辆 ID
    }
  })
}



// 指派车辆
export function assignCarToOrder(orderNumber, carId) {
  return request({
    url: '/lgorder/order/assignCar', // 后端接收指派车辆的接口路径
    method: 'post',
    data: {
      orderNumber: orderNumber, // 传递订单编号
      carId: carId // 传递车辆 ID
    }
  })
}

//调用仓库类型
export function getWarehouseType() {
  return request({
    url: '/lgorder/order/getColdSome',
    method: 'get'
  })
}
//调用单位
export function geUnitType() {
  return request({
    url: '/lgorder/order/getUnitAll',
    method: 'get'
  })
}
//调用仓库类型
export function getColdType() {
  return request({
    url: '/lgorder/order/getColdType',
    method: 'get'
  })
}

//调用货物类型
export function getGoodsType() {
  return request({
    url: '/lgorder/order/getParent',
    method: 'get'
  })
}
// export function getSubGoodsByParentId() {
//   return request({
//     url: '/lgorder/order/getParent',
//     method: 'get'
//   })
// }


export function getSubGoodsByParentId(parentId) {
  return request({
    url: `/lgorder/order/getParentId/`+parentId,
    method: 'get'
  })
}

export function listOrders(query) {
  return request({
    url: '/lgorder/goorder/getList',
    method: 'get',
    params: query
  })
}
export function listexport() {
  return request({
    url: '/lgorder/order/export',
    method: 'get',
    responseType: 'blob'  // 以二进制流的形式处理响应
  })
}
